function res = GetMainField(obj, varargin)
    import MeasurementComponent.Signal.*
    L = log4m.getLogger;
    
    p=inputParser;
    p.addParameter('initialField', 6.0, @(x) x>0);
    p.addParameter('resonantFrequency', 100e3, @(x) x>0);
    p.addParameter('drivingAmplitude', 0.1, @(x) x>0);
    p.addParameter('bzMin', 0.0, @(x) x>=0);
    p.addParameter('bzMax', 7.0, @(x) x>=0);
    p.addParameter('npoint', 100, @(x) x>0);
    p.addParameter('average', 100, @(x) x>0);
    p.addParameter('order', 4, @(x) ismember(x, 1:8));
    p.addParameter('bandwidth', 100, @(x) x>0);    
    p.addParameter('fittingWidth', 1.0, @(x) x>0);
    p.addParameter('isFixBz0', false, @islogical);
    p.addParameter('isReport', false, @islogical);
    p.addParameter('isPlot',   true, @islogical);
    p.addParameter('description', 'No description.', @ischar);
    p.parse(varargin{:});
    
    % Prepare environment
    obj.setRFMagnetometer('field', p.Results.initialField, 'frequency', p.Results.resonantFrequency, 'amplitude', p.Results.drivingAmplitude, ...
                          'signalOscillator', 1, 'order', p.Results.order, 'bandwidth', p.Results.bandwidth);

    % Get Data & fitting
	obj.rbSignal.unsubscribe_signal();
    obj.rbSignal.subscribe_signal(ziDemodTime.R_avg, [2 1 1]);
    obj.rbSignal.subscribe_signal(ziDemodTime.Theta_avg, [2 1 2]);
    swprData = obj.rbSignal.getParameterDependence(obj.ziSlave, ziSweepNode.AuxOut3_Offset, p.Results.bzMin, p.Results.bzMax, 'npoint', p.Results.npoint, 'averaging_sample', p.Results.average);
    fitting = obj.FitMainField(swprData, [p.Results.initialField-p.Results.fittingWidth, p.Results.initialField+p.Results.fittingWidth], varargin{:});
    
    % Post operations

    obj.bz0.setDC(fitting.bz0); pause(0.5);
    L.info('NMRGyroscope::GetMainField', sprintf('Main field Control voltage is set to [%5.3f] V', fitting.bz0));
    phase0 = obj.rbSignal.autoZeroPhase();
    L.info('NMRGyroscope::GetMainField', sprintf('Demod Phase is set to [%5.3f]', phase0));
    obj.by.disable();

    % System Information
    res.timestamp = datetime('now');
    res.signal = swprData;
    res.fitting = fitting;
    res.f0 = p.Results.resonantFrequency;
    res.phase0 = phase0;
    res.bz0 = fitting.bz0;
    res.width = fitting.width;
    res.hight = fitting.hight;
    obj.SystemInfo.MainField = res;
    
    % Plot
    if p.Results.isPlot
        fig = obj.PlotMainField();
    end
    
    % Report
    if p.Results.isReport
        getReporter;
        rpt.NewRecord(['MainField_' p.Results.description]);
        if p.Results.isPlot
            rpt.AppendFigure(fig, sprintf('MainField %s', p.Results.description));
        end
    end
    
    % Store Data
    getSession;
    sess.addData('MainField', res, p.Results.description);
end